<template>
  <view class="page ui-form-basic">
    <fui-form ref="formRef" :model="form" class="form-wrapper grey" labelWidth="200" labelSize="28" labelWeight="bold">
      <view class="form-block-title">拒绝原因</view>
      <fui-textarea size="28" :maxlength="200" height="200rpx" :isCounter="true" radius="16" v-model="form.auditMsg" placeholder="请输入拒绝原因" textareaBorder></fui-textarea>
    </fui-form>

    <view class="page-btn-wrapper">
      <fui-button v-for="(btn, index) in aftersaleStatus.rejectBtns" :key="index" :text="btn.text" @click="handleClickBtn(btn)" :class="btn.className" height="78rpx" radius="8rpx"></fui-button>
    </view>
  </view>
</template>

<script setup>
import { ref, computed, inject } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { setTitle } from '@/utils/common'
import { AFTERSALE_VIEW_STATUS } from './view'
import { useStore } from 'vuex'

const tab = inject('$tab')
const modal = inject('$modal')
const store = useStore()

const aftersaleCode = ref(null)
const aftersaleStatus = computed(() => aftersaleCode.value ? AFTERSALE_VIEW_STATUS[aftersaleCode.value] : {})
const pageTitle = computed(() => {
  const pageOperation = aftersaleStatus.value.operations.find(item => item.func === 'handleToReject')
  return pageOperation ? pageOperation.text : ''
})

onLoad((option) => {
  aftersaleCode.value = option.aftersaleCode
  setTitle(pageTitle.value)
})

// 发货表单信息
const formRef = ref(null)
const form = ref({})

// 提交表单方法
const handleSubmit = () => {
  if (!form.value.auditMsg) {
    modal.msgError('请输入拒绝原因！')
    return
  }
  console.log('提交拒绝表单')
}

// 返回
const handleBack = () => {
  tab.navigateBack()
}

// 操作栏按钮触发
const handleClickBtn = (btn) => {
  eval(btn.func)(btn)
}
</script>

<style lang="scss" scoped>
@import "@/static/scss/form.scss";
</style>
